/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.Currency;
import edu.cmu.mism.dgjava.data.models.option.OptionModelPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Currency</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.CurrencyImpl#getExchangeRate <em>Exchange Rate</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.CurrencyImpl#getForeignRiskRate <em>Foreign Risk Rate</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CurrencyImpl extends DerivitivesImpl implements Currency {
	/**
	 * The default value of the '{@link #getExchangeRate() <em>Exchange Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExchangeRate()
	 * @generated
	 * @ordered
	 */
	protected static final double EXCHANGE_RATE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getExchangeRate() <em>Exchange Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExchangeRate()
	 * @generated
	 * @ordered
	 */
	protected double exchangeRate = EXCHANGE_RATE_EDEFAULT;

	/**
	 * The default value of the '{@link #getForeignRiskRate() <em>Foreign Risk Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForeignRiskRate()
	 * @generated
	 * @ordered
	 */
	protected static final double FOREIGN_RISK_RATE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getForeignRiskRate() <em>Foreign Risk Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForeignRiskRate()
	 * @generated
	 * @ordered
	 */
	protected double foreignRiskRate = FOREIGN_RISK_RATE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CurrencyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OptionModelPackage.Literals.CURRENCY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getExchangeRate() {
		return exchangeRate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExchangeRate(double newExchangeRate) {
		double oldExchangeRate = exchangeRate;
		exchangeRate = newExchangeRate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.CURRENCY__EXCHANGE_RATE, oldExchangeRate, exchangeRate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getForeignRiskRate() {
		return foreignRiskRate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setForeignRiskRate(double newForeignRiskRate) {
		double oldForeignRiskRate = foreignRiskRate;
		foreignRiskRate = newForeignRiskRate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.CURRENCY__FOREIGN_RISK_RATE, oldForeignRiskRate, foreignRiskRate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OptionModelPackage.CURRENCY__EXCHANGE_RATE:
				return getExchangeRate();
			case OptionModelPackage.CURRENCY__FOREIGN_RISK_RATE:
				return getForeignRiskRate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OptionModelPackage.CURRENCY__EXCHANGE_RATE:
				setExchangeRate((Double)newValue);
				return;
			case OptionModelPackage.CURRENCY__FOREIGN_RISK_RATE:
				setForeignRiskRate((Double)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OptionModelPackage.CURRENCY__EXCHANGE_RATE:
				setExchangeRate(EXCHANGE_RATE_EDEFAULT);
				return;
			case OptionModelPackage.CURRENCY__FOREIGN_RISK_RATE:
				setForeignRiskRate(FOREIGN_RISK_RATE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OptionModelPackage.CURRENCY__EXCHANGE_RATE:
				return exchangeRate != EXCHANGE_RATE_EDEFAULT;
			case OptionModelPackage.CURRENCY__FOREIGN_RISK_RATE:
				return foreignRiskRate != FOREIGN_RISK_RATE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (exchangeRate: ");
		result.append(exchangeRate);
		result.append(", foreignRiskRate: ");
		result.append(foreignRiskRate);
		result.append(')');
		return result.toString();
	}

} //CurrencyImpl
